import java.io.IOException;
import java.io.ObjectInputFilter;

class one implements Cloneable {
    int a = 0;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

//自定义一个异常
class Question_by_me extends Exception{
    public Question_by_me(String Question) {
        super(Question);
    }
}

public class first {
//    //实例内部类
//    class hh{
//        int a = 10;
//    }
//    public static void main(String[] args) {
//        first hhh = new first();
//        first.hh h = hhh.new hh();
//        System.out.println(h.a);
//    }
    public static void hh(String[] hh) throws NullPointerException{
        //throws 异常的声明
        if (hh == null) {
            throw new NullPointerException("空指引用");
        }
    }

    public static void m() {
        try {
            int[] h = {1, 2, 3};
            h = null;
            System.out.println(h.length);
        } catch (NullPointerException e) {
            System.out.println("空指针应用");
            throw  new NullPointerException();
        }finally {
            System.out.println("ed");
        }
    }

    public static void msain(String[] args) {
        m();
    }
    public static void mainaa(String[] args) throws Question_by_me {

//        throw new Question_by_me("出错了,但是是在我意料之中");
        //System.out.println(h());
    }

    //    public static void main(String[] args) {
//        String[] hh = null;
//        hh(hh);
//    }




    public static int h() {
        //try-catch
        int[] hh = {1, 2, 3};
        hh = null;
        try {
            System.out.println(hh[3]);
            System.out.println(hh.length);//空指针引用
            //可能出错误的代码
        } catch (ArrayIndexOutOfBoundsException e) {//要捕获异常类型
            //对错误的解决方法
            System.out.println("越界了");
            throw new ArrayIndexOutOfBoundsException("yuejiele");
        } catch (NullPointerException e) {
            System.out.println("空指针引用");
            throw new NullPointerException("除了啦");
        } catch (Exception e) {
            throw new NullPointerException("除了啦");
        } finally {

            //这里的代码一定会执行
            System.out.println("ed");
            return 1;
        }
    }
    public static void mmain(String[] args) throws CloneNotSupportedException {
        //事前防御型
//        boolean ret = false;
//        ret = first();//成功放回true
//        if (!ret) {
//            System.out.println("first 运行出错");
//        }

        //用try catch 捕捉到错误
//        boolean ret = false;
//        try {
//            ret = first();
//        } catch (ret) {
//
//        }finally {//这个最后必定会执行的
//            System.out.println("over");
//        }
        throw new NullPointerException("你有问题");

    }
    public static void maizn(String[] args) {
        //对于程序的各种报错，如数组越界.ArrayIndexOutOfBoundsException
        // 空指针的访问NullPointerException
        int[] a = new int[1];
        System.out.println(a[1]);
    }
}
